home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '87 / Source ƒ.sea / Source ƒ / emacs source ƒ / ESTRUCT.H < prev    next >
Encoding:
Text File  |  1992-06-28  |  14.6 KB  |  352 lines  |  [TEXT/MARC]

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.7
  3.  
  4.             written by Dave G. Conroy
  5.             modified by Steve Wilhite, George Jones
  6.             greatly modified by Daniel Lawrence
  7. */
  8.  
  9. #undef    LATTICE        /* don't use their definitions...use ours    */
  10. #undef    MSDOS
  11. #undef    CPM
  12. #undef    AMIGA
  13.  
  14. /*    Version definition            */
  15.  
  16. #define    VERSION    "3.7i"
  17.  
  18. /*    Machine/OS definitions            */
  19.  
  20. #define AMIGA   0                       /* AmigaDOS            */
  21. #define ST520   0                       /* ST520, TOS                   */
  22. #define MSDOS   1                       /* MS-DOS                       */
  23. #define V7      0                       /* V7 UN*X or Coherent or BSD4.2*/
  24. #define    BSD    0            /* UNIX BSD 4.2    and ULTRIX    */
  25. #define    USG    0            /* UNIX system V        */
  26. #define VMS     0                       /* VAX/VMS                      */
  27. #define CPM     0                       /* CP/M-86                      */
  28. #define    FINDER    0            /* Macintosh OS            */
  29.  
  30. /*    Compiler definitions            */
  31. #define MWC86   0    /* marc williams compiler */
  32. #define    LATTICE    0    /* either lattice compiler */
  33. #define    LAT2    0    /* Lattice 2.15 */
  34. #define    LAT3    0    /* Lattice 3.0 */
  35. #define    AZTEC    1    /* Aztec C 3.20e */
  36. #define    MSC    0    /* MicroSoft C compile version 3 */
  37.  
  38. /*    Profiling options    */
  39. #define    APROF    0    /* turn Aztec C profiling on? */
  40. #define    NBUCK    100    /* number of buckets to profile */
  41.  
  42. /*   Special keyboard definitions            */
  43.  
  44. #define WANGPC    0            /* WangPC - mostly escape sequences     */
  45.  
  46. /*    Terminal Output definitions        */
  47.  
  48. #define ANSI    0            /* ansi escape sequences    */
  49. #define    HP150    0            /* HP150 screen driver        */
  50. #define    HP110    0            /* HP110 screen driver        */
  51. #define    VMSVT    0            /* various VMS terminal entries    */
  52. #define VT52    0                       /* VT52 terminal (Zenith).      */
  53. #define VT100   0                       /* Handle VT100 style keypad.   */
  54. #define LK201   0                       /* Handle LK201 style keypad.   */
  55. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  56. #define TERMCAP 0                       /* Use TERMCAP                  */
  57. #define    IBMPC    1            /* IBM-PC CGA specific driver    */
  58. #define    IBMMONO    0            /* IBM-PC Monochrome driver    */
  59. #define    EGA    0            /* EGA IBM-PC specific driver    */
  60. #define    DG10    0            /* Data General system/10    */
  61. #define    TIPC    0            /* TI Profesional PC driver    */
  62. #define    MAC    0            /* Macintosh            */
  63.  
  64. /*    Configuration options    */
  65.  
  66. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  67. #define    NFWORD    1    /* forward word jumps to beginning of word    */
  68. #define    CLRMSG    0    /* space clears the message line with no insert    */
  69. #define    ACMODE    1    /* auto CMODE on .C and .H files        */
  70. #define    CFENCE    1    /* fench matching in CMODE            */
  71. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  72. #define DEBUGM    1    /* Global SPELL mode triggers macro debugging    */
  73.  
  74. #define    REVSTA    1    /* Status line appears in reverse video        */
  75. #define    COLOR    1    /* color commands and windows            */
  76. #define    FLICKER    0    /* flicker suppression on mem mapped drivers    */
  77. #define    NFLICK    1    /* # of lines to display before flicker check    */
  78.  
  79. #define    FILOCK    0    /* file locking under unix BSD 4.2        */
  80. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  81. #define    WORDPRO    1    /* Advanced word processing features        */
  82. #define    FLABEL    0    /* function key label code            */
  83. #define    APROP    1    /* Add code for Apropos command            */
  84. #define    CRYPT    1    /* file encryption enabled?            */
  85.  
  86. /*    System dependant library redefinitions, structures and includes    */
  87.  
  88. #if    MSDOS & AZTEC
  89. #undef    fputc
  90. #undef    fgetc
  91. #define    fputc    aputc
  92. #define    fgetc    agetc
  93. #define    int86    sysint
  94. #define    inp    inportb
  95.  
  96. struct XREG {
  97.     int ax,bx,cx,dx,si,di;
  98. };
  99.  
  100. struct HREG {
  101.     char al,ah,bl,bh,cl,ch,dl,dh;
  102. };
  103.  
  104. union REGS {
  105.     struct XREG x;
  106.     struct HREG h;
  107. };
  108. #endif
  109.  
  110. #if    MSDOS & MSC
  111. #include    <dos.h>
  112. #define    movmem(a, b, c)        memcpy(b, a, c)
  113. #endif
  114.  
  115. #if    MSDOS & LATTICE
  116. #undef    CPM
  117. #undef    LATTICE
  118. #include    <dos.h>
  119. #undef    CPM
  120. #endif
  121.  
  122. #if    VMS
  123. #define    unlink(a)    delete(a)
  124. #endif
  125.  
  126. /*    define memory mapped flag    */
  127.  
  128. #define    MEMMAP    0
  129.  
  130. #if    IBMPC
  131. #undef    MEMMAP
  132. #define    MEMMAP    1
  133. #endif
  134.  
  135. #if    EGA
  136. #undef    MEMMAP
  137. #define    MEMMAP    1
  138. #endif
  139.  
  140. /*    internal constants    */
  141.  
  142. #define    NBINDS    200            /* max # of bound keys        */
  143. #define NFILEN  80                      /* # of bytes, file name        */
  144. #define NBUFN   16                      /* # of bytes, buffer name      */
  145. #define NLINE   256                     /* # of bytes, line             */
  146. #define    NSTRING    256            /* # of bytes, string buffers    */
  147. #define NKBDM   256                     /* # of strokes, keyboard macro */
  148. #define NPAT    80                      /* # of bytes, pattern          */
  149. #define HUGE    1000                    /* Huge number                  */
  150. #define    NLOCKS    100            /* max # of file locks active    */
  151. #define    NCOLORS    8            /* number of supported colors    */
  152. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  153. #define    NBLOCK    16            /* line block chunk size    */
  154.  
  155. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  156. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  157. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  158. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  159. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  160. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  161.  
  162. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  163. #define META    0x0200                  /* Meta flag, or'ed in          */
  164. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  165. #define    SPEC    0x0800            /* special key (function keys)    */
  166.  
  167. #define FALSE   0                       /* False, no, bad, etc.         */
  168. #define TRUE    1                       /* True, yes, good, etc.        */
  169. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  170. #define    FAILED    3            /* not-quite fatal false return    */
  171.  
  172. #define FIOSUC  0                       /* File I/O, success.           */
  173. #define FIOFNF  1                       /* File I/O, file not found.    */
  174. #define FIOEOF  2                       /* File I/O, end of file.       */
  175. #define FIOERR  3                       /* File I/O, error.             */
  176. #define    FIOLNG    4            /*line longer than allowed len    */
  177.  
  178. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  179. #define CFKILL  0x0002                  /* Last command was a kill      */
  180.  
  181. #define    BELL    0x07            /* a bell character        */
  182. #define    TAB    0x09            /* a tab character        */
  183.  
  184. /*
  185.  * There is a window structure allocated for every active display window. The
  186.  * windows are kept in a big list, in top to bottom screen order, with the
  187.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  188.  * The flag field contains some bits that are set by commands to guide
  189.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  190.  * the full blown redisplay is just too expensive to run for every input
  191.  * character.
  192.  */
  193. typedef struct  WINDOW {
  194.         struct  WINDOW *w_wndp;         /* Next window                  */
  195.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  196.         struct  LINE *w_linep;          /* Top line in the window       */
  197.         struct  LINE *w_dotp;           /* Line containing "."          */
  198.         short   w_doto;                 /* Byte offset for "."          */
  199.         struct  LINE *w_markp;          /* Line containing "mark"       */
  200.         short   w_marko;                /* Byte offset for "mark"       */
  201.         char    w_toprow;               /* Origin 0 top row of window   */
  202.         char    w_ntrows;               /* # of rows of text in window  */
  203.         char    w_force;                /* If NZ, forcing row.          */
  204.         char    w_flag;                 /* Flags.                       */
  205. #if    COLOR
  206.     char    w_fcolor;        /* current forground color    */
  207.     char    w_bcolor;        /* current background color    */
  208. #endif
  209. }       WINDOW;
  210.  
  211. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  212. #define WFMOVE  0x02                    /* Movement from line to line   */
  213. #define WFEDIT  0x04                    /* Editing within a line        */
  214. #define WFHARD  0x08                    /* Better to a full display     */
  215. #define WFMODE  0x10                    /* Update mode line.            */
  216. #define    WFCOLR    0x20            /* Needs a color change        */
  217.  
  218. /*
  219.  * Text is kept in buffers. A buffer header, described below, exists for every
  220.  * buffer in the system. The buffers are kept in a big list, so that commands
  221.  * that search for a buffer by name can find the buffer header. There is a
  222.  * safe store for the dot and mark in the header, but this is only valid if
  223.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  224.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  225.  * the header line in "b_linep".
  226.  *     Buffers may be "Inactive" which means the files accosiated with them
  227.  * have not been read in yet. These get read in at "use buffer" time.
  228.  */
  229. typedef struct  BUFFER {
  230.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  231.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  232.         short   b_doto;                 /* Offset of "." in above LINE  */
  233.         struct  LINE *b_markp;          /* The same as the above two,   */
  234.         short   b_marko;                /* but for the "mark"           */
  235.         struct  LINE *b_linep;          /* Link to the header LINE      */
  236.     char    b_active;        /* window activated flag    */
  237.         char    b_nwnd;                 /* Count of windows on buffer   */
  238.         char    b_flag;                 /* Flags                        */
  239.     char    b_mode;            /* editor mode of this buffer    */
  240.         char    b_fname[NFILEN];        /* File name                    */
  241.         char    b_bname[NBUFN];         /* Buffer name                  */
  242. #if    CRYPT
  243.     char    b_key[NPAT];        /* current encrypted key    */
  244. #endif
  245. }       BUFFER;
  246.  
  247. #define BFINVS  0x01                    /* Internal invisable buffer    */
  248. #define BFCHG   0x02                    /* Changed since last write     */
  249.  
  250. /*    mode flags    */
  251. #define    NUMMODES    8        /* # of defined modes        */
  252.  
  253. #define    MDWRAP    0x0001            /* word wrap            */
  254. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  255. #define    MDSPELL    0x0004            /* spell error parcing        */
  256. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  257. #define    MDVIEW    0x0010            /* read-only buffer        */
  258. #define MDOVER    0x0020            /* overwrite mode        */
  259. #define MDMAGIC    0x0040            /* regular expresions in search */
  260. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  261.  
  262. /*
  263.  * The starting position of a region, and the size of the region in
  264.  * characters, is kept in a region structure.  Used by the region commands.
  265.  */
  266. typedef struct  {
  267.         struct  LINE *r_linep;          /* Origin LINE address.         */
  268.         short   r_offset;               /* Origin LINE offset.          */
  269.         long    r_size;                 /* Length in characters.        */
  270. }       REGION;
  271.  
  272. /*
  273.  * All text is kept in circularly linked lists of "LINE" structures. These
  274.  * begin at the header line (which is the blank line beyond the end of the
  275.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  276.  * number of bytes in the line (the "used" size), the size of the text array,
  277.  * and the text. The end of line is not stored as a byte; it's implied. Future
  278.  * additions will include update hints, and a list of marks into the line.
  279.  */
  280. typedef struct  LINE {
  281.         struct  LINE *l_fp;             /* Link to the next line        */
  282.         struct  LINE *l_bp;             /* Link to the previous line    */
  283.         short   l_size;                 /* Allocated size               */
  284.         short   l_used;                 /* Used size                    */
  285.         char    l_text[1];              /* A bunch of characters.       */
  286. }       LINE;
  287.  
  288. #define lforw(lp)       ((lp)->l_fp)
  289. #define lback(lp)       ((lp)->l_bp)
  290. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  291. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  292. #define llength(lp)     ((lp)->l_used)
  293.  
  294. /*
  295.  * The editor communicates with the display using a high level interface. A
  296.  * "TERM" structure holds useful variables, and indirect pointers to routines
  297.  * that do useful operations. The low level get and put routines are here too.
  298.  * This lets a terminal, in addition to having non standard commands, have
  299.  * funny get and put character code too. The calls might get changed to
  300.  * "termp->t_field" style in the future, to make it possible to run more than
  301.  * one terminal type.
  302.  */
  303. typedef struct  {
  304.         short   t_nrow;                 /* Number of rows.              */
  305.         short   t_ncol;                 /* Number of columns.           */
  306.     short    t_margin;        /* min margin for extended lines*/
  307.     short    t_scrsiz;        /* size of scroll region "    */
  308.     int    t_pause;        /* # times thru update to pause */
  309.         int     (*t_open)();            /* Open terminal at the start.  */
  310.         int     (*t_close)();           /* Close terminal at end.       */
  311.     int    (*t_kopen)();        /* Open keyboard        */
  312.     int    (*t_kclose)();        /* close keyboard        */
  313.         int     (*t_getchar)();         /* Get character from keyboard. */
  314.         int     (*t_putchar)();         /* Put character to display.    */
  315.         int     (*t_flush)();           /* Flush output buffers.        */
  316.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  317.         int     (*t_eeol)();            /* Erase to end of line.        */
  318.         int     (*t_eeop)();            /* Erase to end of page.        */
  319.         int     (*t_beep)();            /* Beep.                        */
  320.     int    (*t_rev)();        /* set reverse video state    */
  321. #if    COLOR
  322.     int    (*t_setfor)();        /* set forground color        */
  323.     int    (*t_setback)();        /* set background color        */
  324. #endif
  325. }       TERM;
  326.  
  327. /*    structure for the table of initial key bindings        */
  328.  
  329. typedef struct  {
  330.         short   k_code;                 /* Key code                     */
  331.         int     (*k_fp)();              /* Routine to handle it         */
  332. }       KEYTAB;
  333.  
  334. /*    structure for the name binding table        */
  335.  
  336. typedef struct {
  337.     char *n_name;        /* name of function key */
  338.     int (*n_func)();    /* function name is bound to */
  339. }    NBIND;
  340.  
  341. /*    The editor holds deleted text chunks in the KILL buffer. The
  342.     kill buffer is logically a stream of ascii characters, however
  343.     due to its unpredicatable size, it gets implemented as a linked
  344.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  345.     was taken up by the keycode structure            */
  346.  
  347. typedef    struct KILL {
  348.     struct KILL *d_next;    /* link to next chunk, NULL if last */
  349.     char d_chunk[KBLOCK];    /* deleted text */
  350. } KILL;
  351.  
  352.